package com.ergwang.service.admin;

import com.ergwang.Model.User;
import com.ergwang.Model.mall.bo.UserLoginBO;
import com.ergwang.dao.UserDao;
import com.ergwang.dao.UserDaoImpl;

import java.util.List;

/**
 * Creat by ergWang
 * Date: 2020/5/30
 * Time: 09:40
 * @author ergwang
 */
public class UserServiceImpl implements UserService{

    private UserDao userDao = new UserDaoImpl();

    public List<User> allUser() {
        return userDao.allUser();
    }

    public List<User> searchUser(String word) {
        return userDao.searchUser(word);
    }

    public int deleteUser(String id) {
        return userDao.deleteUser(id);
    }

    public User login(UserLoginBO userLoginBO) {
        User user = new User();
        user.setEmail(userLoginBO.getEmail());
        user.setPwd(userLoginBO.getPwd());
        return userDao.login(user);
    }

    public User signup(User user) {
        userDao.signup(user);
        UserLoginBO userLoginBO = new UserLoginBO();
        userLoginBO.setEmail(user.getEmail());
        userLoginBO.setPwd(user.getPwd());
        return login(userLoginBO);
    }
}
